﻿using System;
using System.Collections.Generic;
using ContractManager.Common.Class;
using ContractManager.Entity;
using Speed.Data;

namespace ContractManager.BLL.Business
{
    public static class ClsDocumentTypes
    {
        public static List<DocumentTypes> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.DocumentTypes.Select(db);
            }
            
        }

        public static void Insert(DocumentTypes capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<DocumentTypes>(capital, EnumSaveMode.Requery);
            }
            
        }

        public static void Update(DocumentTypes capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<DocumentTypes>(capital);
            }
            
        }

        public static DocumentTypes SelectByPk(Int32 docTypId)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<DocumentTypes>(string.Format("DocTypId={0}", docTypId));
            }
            
        }

        public static DocumentTypes SelectByCode(string docTypCode)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<DocumentTypes>(string.Format("DocTypCode='{0}'", docTypCode));
            }
            
        }

        public static int DeleteByPk(Int32 docTypId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<DocumentTypes>(string.Format("DocTypId={0}", docTypId));
            }
            
        }
    }
}